<template>
  <a-tooltip content="选择一个大模型" background-color="#3491FA">
    <a-select v-model="selectedModel" placeholder="请选择模型" style="width: 100%;">
      <a-option v-for="item in modelOptions" :key="item.value" :value="item.value">{{ item.label }}</a-option>
    </a-select>
  </a-tooltip>
</template>

<script setup>
import { ref, watch } from 'vue';

// 接收父组件传入的 v-model 值
const props = defineProps({
  modelValue: {
    type: [Number, null],
    default: null
  }
});

const emits = defineEmits(['update:modelValue']);

// 内部的选中模型
const selectedModel = ref(props.modelValue);

// 监听内部选中模型的变化，并更新父组件的 v-model
watch(selectedModel, (newValue) => {
  emits('update:modelValue', newValue);
});

// 模型选项
const modelOptions = [
  {
    label: "DeepSeek-v3",
    value: 917,
  },
  {
    label: "DouBao-Pro-32k",
    value: 420,
  },
  {
    label: "ChatGLM4",
    value: 625,
  },
  {
    label: "ChatGLM4v",
    value: 331,
  },
];

// 平台列表
const platformListOfZhiPu = ref([
  625,
  331
]);

const platformListOfVolcano = ref([
  917,
  420
]);

// 根据选中的模型获取对应的平台
const getPlatform = (model) => {
  if (platformListOfZhiPu.value.includes(model)) {
    return 0;
  } else if (platformListOfVolcano.value.includes(model)) {
    return 1;
  }
  return null;
};

defineExpose({
  getPlatform
})

// 监听选中模型的变化，可根据需求添加其他逻辑
watch(selectedModel, (newModel) => {
  getPlatform(newModel);
});
</script>

<style scoped>
</style>
